package cn.edu.ctbu.datajpa01.repository;

import cn.edu.ctbu.datajpa01.domain.Student;
import cn.edu.ctbu.datajpa01.domain.Teacher;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;
import java.util.Optional;

public interface TeacherRepository extends JpaRepository<Teacher,Integer> {


    @Query("select t from tb_teacher t where substring(t.id,1,4)="+
                  "(select substring(MAX(t1.id),1,4)from tb_teacher t1 group by substring(t1.id,1,4)having count(*)>1)")

    List<Teacher> findTeacherWithSamePrefix();
}

